<?php 
	$this -> load -> view('header'); ?>
<!-- BEGIN CONTAINER -->
<div class="page-container row-fluid" id="ancho">
	<?php //$this -> load -> view('sidebar'); ?>
	<!-- BEGIN PAGE -->
	<div class="page-content" >
		<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
		<div id="portlet-config" class="modal hide">
			<div class="modal-header">
				<button data-dismiss="modal" class="close" type="button"></button>
				<h3>portlet Settings</h3>
			</div>
			<div class="modal-body">
				<p>
					Here will be a configuration form
				</p>
			</div>
		</div>
		<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
		<!-- BEGIN PAGE CONTAINER-->
		<div class="container-fluid">
			<!-- BEGIN PAGE HEADER-->
			<div class="row-fluid">
				<div class="span12">
					<h3 class="page-title"> Daftar Laporan</h3>
					<?php $this -> load -> view('breadcrumb'); ?>
				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->
			<div class="row-fluid">
				<div class="span12">
					<form action="<?php echo base_url()?>inbox/save" method="post" id="editReportFrm" class="form-horizontal" enctype="multipart/form-data">
					<div class="tabbable tabbable-custom boxless">
						<ul class="nav nav-tabs">
							<li class="active">
								<a class="advance_form_with_chosen_element" href="#tab_1" data-toggle="tab">Isi Laporan</a>
							</li>
							<li >
								<a class="advance_form_with_chosen_element" href="#table" data-toggle="tab" id="dtPesertaTab" style="display:none">Data Peserta</a>
							</li>					
							<li >
								<a class="advance_form_with_chosen_element" href="#attachmentTab" data-toggle="tab">Dokumen Pendukung</a>
							</li>
							
							
							<li >
								<a class="advance_form_with_chosen_element" href="#kontribusiTab" id="dtKontribusiTab" data-toggle="tab">Kontribusi</a>
							</li>
							
									
							<?php if ($berkasComments!=NULL && count($berkasComments)) {?>
							<li >
								<a class="advance_form_with_chosen_felement" href="#chatTab" data-toggle="tab">Catatan/Komentar</a>
							</li>						
							<?php } ?>	
						</ul>
						<div class="tab-content">
							<div class="tab-pane active" id="tab_1">
								<div class="portlet box green">
									<div class="portlet-title">
										<h4><i class="icon-reorder"></i>Formulir Laporan</h4>
										<div class="tools">
											<a href="javascript:;" class="collapse"></a>
											<a href="#portlet-config" data-toggle="modal" class="config"></a>
											<a href="javascript:;" class="reload"></a>
											<a href="javascript:;" class="remove"></a>
										</div>
									</div>
									<div class="portlet-body form">
										<!-- BEGIN FORM-->
										
											<input type="hidden" name="Berkas.id" value="<?php echo $id?>"/>
											<input type="hidden" name="Profile.id" value="<?php echo $selectedProfile?>"/>
											<input type="hidden" name="BerkasComment.text" id="berkasNote" value=""/>
											<!--<h3 class="form-section">Isi Laporan</h3>-->
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Kab/Kota</label>
														<div class="controls">
															<select class="span8 chosen" data-placeholder="Pilih Kab/Kota" name="Berkas.distrik" id="distrik">
																<?php
																	$isSelected = '';
																	echo "<option value='-1' >--Pilih Kab/Kota--</option>";
																	foreach ($distrikList as $row){
					
																		if ($berkas != NULL){
																			
																			if ($berkas->getPerpustakaan()->getDesa()->getDistrik()->getId()==$row->getId()){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																	}
																?>																
															</select>
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Jenis Laporan</label>
														<?php if ($isDqa==false) {?>
														<div class="controls">
															<select class="large m-wrap span6" name="Berkas.tipe" id="tipeBerkas">
																	<option value='-1'>--Pilih Jenis Laporan--</option>
																<?php
																	$isSelected = '';
																	foreach ($tipeBerkasList as $row){
																		if ($berkas != NULL){
																			if ($berkas->getTipe()->getId()==$row->getId()){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																	}
																?>																
															</select>
															<!--<span class="help-block">This is inline help</span>-->
														</div>
														<?php } else { ?>
														<div class="controls">
															<select class="large m-wrap span6" name="Berkas.tipe" id="tipeBerkas">
																<option value='TRAINING'>Kegiatan Perpuseru</option>																																
															</select>
															<!--<span class="help-block">This is inline help</span>-->
														</div>
														<?php } ?>
													</div>
												</div>
											</div>
											
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Desa</label>
														<div class="controls">
															<select class="span8 chosen" data-placeholder="Pilih Desa" name="Desa.id" id="desa">
																<?php
																	$isSelected = '';
																	echo "<option value='-1' >--Pilih Desa--</option>";
																	if ($desaList != null){
																		foreach ($desaList as $row){																		
																			if ($berkas != NULL){
																				if ($berkas->getPerpustakaan()->getDesa()->getId()==$row->getId()){
																					$isSelected = "selected='selected'";
																				} else {
																					$isSelected = "";
																				}
																			}
																		    echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																		}
																	}
																	//die("---");
																?>																
															</select>
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group" style="display: none" id="jenisTrainingGroup">
														<label class="control-label">Rincian Laporan</label>
														<div class="controls">
															<select class="large m-wrap span6" name="BerkasTraining.jenisTraining" id="jenisTraining">
																<option value='-1'>--Pilih Rincian Laporan--</option>
															<?php
																	$isSelected = '';
																	//$quarterYears = getFiscalYear();
																	foreach ($jenisTrainingList as $row){
																		if ($berkasTraining != NULL){
																			if ($berkasTraining->getJenisTraining()==$row){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																	}
																?>
															</select>	
														</div>
													</div>
													
													<div class="control-group" style="display: none" id="kategoriKegiatanGroup">
														<label class="control-label">Kategori Kegiatan</label>
														<div class="controls">
															<select class="large m-wrap span6" name="kategoriKegiatan" id="kategoriKegiatan">
																<option value='-1'>--Pilih Kategori Kegiatan--</option>
															<?php
																	$isSelected = '';
																	//$quarterYears = getFiscalYear();
																	foreach ($kategoriKegiatanList as $row){
																		if ($berkasLkpm != NULL){
																			if ($berkasLkpm->getJenisKegiatan() != NULL && $berkasLkpm->getJenisKegiatan()->getKategori()==$row){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																	}
																?>
															</select>	
														</div>
													</div>
												</div>
											</div>
											
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Nama Perpustakaan</label>
														<div class="controls">
															<select class="large m-wrap chosen" name="Berkas.perpustakaan" data-placeholder="--Pilih Perpustakaan--" id="perpus">
																<?php
																	$isSelected = '';
																	echo "<option value='-1' >--Pilih Perpustakaan--</option>";
																	if ($perpusList != NULL){
																		foreach ($perpusList as $row){
																			if ($berkas != NULL){
																				if ($berkas->getPerpustakaan()->getId()==$row->getId()){
																					$isSelected = "selected='selected'";
																				} else {
																					$isSelected = "";
																				}
																			}
																			echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																		}	
																	}
																	
																?>																
															</select>
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group" style="display: none" id="jenisKegiatanGroup">
														<label class="control-label">Jenis Kegiatan</label>
														<div class="controls">
															<select class="large m-wrap span6" name="BerkasLkpm.jenisKegiatan" id="jenisKegiatan">
																<option value='-1'>--Pilih Jenis Kegiatan--</option>
															<?php
																	$isSelected = '';
																	//$quarterYears = getFiscalYear();
																	if ($berkasLkpm != NULL){
																		foreach ($jenisKegiatanList as $row){																		
																			if ($berkasLkpm->getJenisKegiatan() != NULL && $berkasLkpm->getJenisKegiatan()->getId()==$row->getId()){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																			echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																		}
																		
																	}
																?>
															</select>	
														</div>
													</div>
												</div>
											</div>
											
											<div class="row-fluid" id="eventDateSection" style="display: none">
												<div class="span5 ">
													<div class="control-group">
														<label class="control-label">Event Date</label>
														<div class="controls">
															<div class="input-append">
                                    							<input name="Berkas.eventDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkas!=NULL && $berkas->getEventDate() != NULL)? $berkas->getEventDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
												
												<div class="span7 ">
													<!-- KOSONG -->													
													
												</div>
											</div>
											
											<!--<div class="row-fluid">
											  	<div class="span12">
											  		
											  	</div>
											</div> -->
											
											<div class="row-fluid">
											  	<div class="span12">
											  		<div class="control-group">
						                              <label class="control-label">Gambaran Singkat Kegiatan</label>
						                              <div class="controls">
						                              	<i>Tuliskan gambaran kegiatan secara umum, mulai dari gambaran singkat pelaksanaan kegiatan, kondisi peserta dan informasi lain yang menurut Anda sesuai untuk menggambarkan pelaksanaan kegiataan</i>
						                                 <textarea class="span12 wysihtml5 m-wrap" id="description" rows="6" name="Berkas.description"><?php echo ($berkas!=NULL)? $berkas->getDescription():""; ?></textarea>
						                              </div>
						                           </div>
											  	</div>
											</div> 
											
											<div class="row-fluid">
											  	<div class="span12">
											  		<div class="control-group">
						                              <label class="control-label">Hasil Kegiatan</label>
						                              <div class="controls">
						                              	<i>Tuliskan hasil dari kegiatan ini seperti kesepakatan, tanggapan peserta, sebuah produk atau bentuk hasil – hasil kegiatan lainnya. Jika kegiatan menghasilkan kesepakatan tindak lanjut, silahkan tuliskan juga tindak lanjut apa yang disepakati atau direncanakaan</i>
						                                 <textarea class="span12 m-wrap" id="hasilKegiatan" rows="6" name="Berkas.hasilKegiatan"><?php echo ($berkas!=NULL)? $berkas->getHasilKegiatan():""; ?></textarea>
						                              </div>
						                           </div>
											  	</div>
											</div>
											
											<div class="row-fluid">
											  	<div class="span12">
											  		<div class="control-group">
						                              <label class="control-label">Tantangan Kegiatan</label>
						                              <div class="controls">
						                              	 <i>Tuliskan tantangan dalam pelaksanaan kegiatan ini. Jika menurut Anda dalam melaksanakan kegiatan tidak ada tantangan yang berarti (dapat diselesaikan dengan baik) Anda boleh untuk tidak melaporkannya.</i>
						                                 <textarea class="span12 m-wrap" id="tantangan" rows="6" name="Berkas.tantangan"><?php echo ($berkas!=NULL)? $berkas->getTantangan():""; ?></textarea>
						                              </div>
						                           </div>
											  	</div>
											</div>

											<!--/row-->
										<div id="detailSection" style="display: none">	
											<h3 class="form-section"></h3>
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Tanggal Mulai Training</label>
														<div class="controls">
															<div class="input-append">
                                    							<input id="BerkasTrainingFromDate" name="BerkasTraining.fromDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkasTraining!=NULL && $berkasTraining->getFromDate() != NULL)? $berkasTraining->getFromDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Tanggal Selesai Training</label>
														<div class="controls">
															<div class="input-append">
                                    							<input id="BerkasTrainingToDate" name="BerkasTraining.toDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkasTraining!=NULL && $berkasTraining->getToDate() != NULL)? $berkasTraining->getToDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
											</div>
											<div class="row-fluid" id="trainingDetailGroup" >
												<div class="span6">
													<div class="control-group">
														<label class="control-label">Jumlah Staff/Non Staff</label>
														<div class="controls">
															<input type="text" class="m-wrap span2 onlynumber" readonly="true" placeholder="0" name="BerkasTraining.jmlStaff" id="participantTotalStaff" value="<?php echo ($berkasTraining != NULL)? $berkasTraining->getJmlStaff():"";?>" />
															<span class="help-inline">Staff</span>
															
															<input type="text" class="m-wrap span2 onlynumber" placeholder="0" readonly="true" name="BerkasTraining.jmlNonStaff" id="participantTotalNonStaff" value="<?php echo ($berkasTraining != NULL)? $berkasTraining->getJmlNonStaff():"";?>" />
															<span class="help-inline">Non Staff</span>
															
															<input type="text" class="m-wrap span2 onlynumber" placeholder="0" readonly="true" name="BerkasTraining.jmlLainnya" id="participantTotalLainnya" value="<?php echo ($berkasTraining != NULL)? $berkasTraining->getJmlLainnya():"";?>" />
															<span class="help-inline">Lainnya</span>																														
														</div>
													</div>													
												</div>

												<!--/span-->
												<div class="span6">
													<div class="control-group">
														<label class="control-label">Jumlah Jenis Kelamin</label>
														<div class="controls">
															<input type="text" class="m-wrap span3 onlynumber" placeholder="0" name="BerkasTraining.jmlPria" readonly="true" id="participantTotalMale" value="<?php echo ($berkasTraining != NULL)? $berkasTraining->getJmlPria():"";?>" />
															<span class="help-inline">Laki-Laki</span>
															&nbsp;
															<input type="text" class="m-wrap span3 onlynumber" placeholder="0" name="BerkasTraining.jmlWanita" readonly="true" id="participantTotalFemale" value="<?php echo ($berkasTraining != NULL)? $berkasTraining->getJmlWanita():"";?>" />
															<span class="help-inline">Perempuan</span>																														
														</div>
													</div>													
												</div>
												<!--/span-->
											</div>
											<!--/row-->
											
											<div class="row-fluid" id="trainingDetailGroup2">
												<div class="span6">
													<div class="control-group">
														<label class="control-label">Total</label>
														<div class="controls">
															<input type="text" class="m-wrap span3 onlynumber" placeholder="0" name="total" readonly="true" id="participantTotal" value="<?php echo ($berkasTraining != NULL)? ($berkasTraining->getJmlPria() + $berkasTraining->getJmlWanita()) : "";?>">
															&nbsp; <button class="btn blue" type="button" id="btnEditMember"><i class="icon-pencil"></i> Masukkan Data Peserta Pelatihan</button>																																													
														</div>
													</div>													
												</div>

												<!--/span-->
												<div class="span6">
													<!--<div class="control-group">
														<a href="#myModal3" role="button" class="btn btn-warning" data-toggle="modal" id="findCategory">Find</a>
													</div>-->													
												</div>
												<!--/span-->
											</div>
											<!--/row-->
										</div>
										
										<div id="lkpmDetailSection" style="display: none">	
											<h3 class="form-section"></h3>
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Tanggal Mulai Kegiatan</label>
														<div class="controls">
															<div class="input-append">
                                    							<input id="BerkasLkpmFromDate" name="BerkasLkpm.fromDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkasLkpm!=NULL && $berkasLkpm->getFromDate() != NULL)? $berkasLkpm->getFromDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Tanggal Selesai Kegiatan</label>
														<div class="controls">
															<div class="input-append">
                                    							<input id="BerkasLkpmToDate" name="BerkasLkpm.toDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkasLkpm!=NULL && $berkasLkpm->getToDate() != NULL)? $berkasLkpm->getToDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
											</div>
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Topik Kegiatan</label>
														<div class="controls">
															<select class="large m-wrap span6" name="BerkasLkpm.topikKegiatan" id="topikKegiatan">
																<option value='-1'>--Pilih Topik Kegiatan--</option>
															<?php
																	$isSelected = '';
																	//$quarterYears = getFiscalYear();
																	foreach ($topikKegiatanList as $row){
																		if ($berkasLkpm != NULL){
																			if ($berkasLkpm->getTopikKegiatan()==$row){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																	}
																?>
															</select>	
														</div>
													</div>
												</div>
												
												<div class="span6">
													<div class="control-group">
														<label class="control-label">Jumlah Jenis Kelamin</label>
														<div class="controls">
															<input type="text" class="m-wrap span3 onlynumber" placeholder="0" name="BerkasLkpm.jumlahPria" id="BerkasLkpmJumlahPria" value="<?php echo ($berkasLkpm != NULL)? $berkasLkpm->getJumlahPria():"";?>" />
															<span class="help-inline">Laki-Laki</span>
															&nbsp;
															<input type="text" class="m-wrap span3 onlynumber" placeholder="0" name="BerkasLkpm.jumlahWanita" id="BerkasLkpmJumlahWanita" value="<?php echo ($berkasLkpm != NULL)? $berkasLkpm->getJumlahWanita():"";?>" />
															<span class="help-inline">Perempuan</span>																														
														</div>
													</div>													
												</div>
											</div>
											<!--/row-->
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														
						                              <label class="control-label" id="sasaranLabel">
						                              	<?php if ($berkasLkpm != NULL){
						                              			//echo strtoupper($berkasLkpm->getJenisKegiatan()->getKategori()->getNama());
						                              			if ($berkasLkpm->getJenisKegiatan() != NULL && strtoupper($berkasLkpm->getJenisKegiatan()->getKategori()->getNama()) == "PERTEMUAN"){
						                              				echo "Sasaran";
						                              			} else {
						                              				echo "Kelompok Sasaran";
						                              			}
						                              		  } else {
						                              		  	echo "Kelompok Sasaran"; 
						                              		  }						                              	
						                              	?></label>
						                              <div class="controls" id="kelompokSasaran">
			                                       	  <?php 
			                                       	  if ($berkasLkpm != NULL){
										                    $criteria = array('berkas' => $berkas);
															$berkasLkpmSasarans = $this -> em -> getRepository('\models\entities\BerkasLkpmSasaran')->findBy($criteria);
															$sasarans = array();
															$institusiLain = '';
															foreach ($berkasLkpmSasarans as $row){
																$sasarans[] = $row->getKelompokSasaran()->getId();
																if ($row->getInstitusiLain() != ""){
																	$institusiLain = $row->getInstitusiLain(); 
																}
															}
															$jenis = 1;
															if ($berkasLkpm->getJenisKegiatan() != NULL && $berkasLkpm->getJenisKegiatan()->getKategori()->getNama() == "Pertemuan"){
																$jenis=2;
															}
															$criteria = array('jenis' => $jenis);
															$kelompokSasaranList = $this -> em -> getRepository('\models\entities\KelompokSasaran')->findBy($criteria);
															foreach ($kelompokSasaranList as $row){
																if (in_array($row->getId(), $sasarans)){
																	$checked = 'checked';
																	$initVal = $institusiLain;
																} else {
																	$checked = '';
																	$initVal = '';	
																}				
																if ($jenis == 1){
																	echo '<label class="checkbox line">
							                                          	<input type="checkbox" name="BerkasLkpmSasaran[]" value="'.$row->getId().'" '.$checked.'/> '.$row->getNama().' &nbsp;&nbsp;&nbsp;                                          													
							                                          </label>';	
																} else {
																	$labelTambahan = "";
																	$spasi = '';
																	if (strtoupper($row->getNama())=="NON PEMERINTAH"){
																		if ($checked == "checked"){
																			$disabled = "";
																		} else {
																			$disabled = "disabled";																			
																		}
																		//$labelTambahan = '<input type="text" value="'.$institusiLain.'" id="kelompokNonPemerintah" name="kelompokNonPemerintah" class="m-wrap span6" '.$disabled.'>';
																		$idx = "radio_1"; 
																		
																	} else {
																		$idx = "radio_2";
																		//$spasi = 'DDDD';	
																		$spasi = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';																	
																	}
																	$labelTambahan = '<input type="text" value="'.$initVal.'" id="kelompokNonPemerintah'.$idx.'" name="kelompokNonPemerintah" class="m-wrap span6" '.$disabled.'>';
																	echo  '<label class="radio line">'.
										                                    '<input type="radio" name="BerkasLkpmSasaran[]" value="'.$row->getId().'" id="' .$idx.'" '.$checked.' onclick="sasaranRadioClickHandler(event)"/>'
										                                  	.$row->getNama().' &nbsp;&nbsp; '.$spasi. $labelTambahan.' 
										                                  </label>
										                                  ';
																}
																										
															}
														} else {
															/*$kelompokSasaranList = $this -> em -> getRepository('\models\entities\KelompokSasaran')->findAll();
															foreach ($kelompokSasaranList as $row){
																echo '<label class="checkbox line">
							                                          	<input type="checkbox" name="BerkasLkpmSasaran[]" value="'.$row->getId().'" /> '.$row->getNama().' &nbsp;&nbsp;&nbsp;                                          													
							                                          </label>
							                                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';																																
															}*/		
														}
			                                       	   
			                                       	  ?>
			                                       	</div>
						                             <!-- <div class="controls">
						                                 <select data-placeholder="Pilih Kelompok Sasaran" name="BerkasLkpmSasaran[]" class="chosen" multiple="multiple" tabindex="6" id="berkasLkpmSasaran">
						                                     <?php
										            /*           		 */
										                        ?>                              
						                                 </select>
						                          </div> -->
						                           </div>
												</div>
												
												<div class="span6">
													<div class="control-group">
														<label class="control-label">Jumlah Total</label>
														<div class="controls">
															<input type="text" class="m-wrap span3 onlynumber" placeholder="0" name="BerkasLkpm.jumlahTotal" id="berkasLkpmJumlahTotal" value="<?php echo ($berkasLkpm != NULL)? $berkasLkpm->getJumlahTotal():"";?>" />
																																													
														</div>
													</div>													
												</div>
											</div>
										</div>
										
										<div id="lasDetailSection" style="display: none">	
											<h3 class="form-section"></h3>
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Tanggal Mulai Kegiatan</label>
														<div class="controls">
															<div class="input-append">
                                    							<input id="BerkasLasFromDate" name="BerkasLas.fromDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkasLas!=NULL && $berkasLas->getFromDate() != NULL)? $berkasLas->getFromDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Tanggal Selesai Kegiatan</label>
														<div class="controls">
															<div class="input-append">
                                    							<input id="BerkasLasToDate" name="BerkasLas.toDate" class="m-wrap m-ctrl-medium date-picker" size="16" type="text" value="<?php echo ($berkasLas!=NULL && $berkasLas->getToDate() != NULL)? $berkasLas->getToDate()->format('d-m-Y'):""; ?>"/>
                                    							<span class="add-on"><i class="icon-calendar"></i></span>
                                 							</div>															
														</div>
													</div>
												</div>
											</div>
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Jenis Asistensi</label>
														<div class="controls">
															<select class="large m-wrap span6" name="BerkasLas.jenisAsistensi" id="BerkasLasJenisAsistensi">
																<option value='-1'>--Pilih Jenis Asistensi--</option>
															<?php
																	$isSelected = '';
																	//$quarterYears = getFiscalYear();
																	for ($i=1; $i<3;$i++){
																		if ($berkasLas != NULL){
																			if ($berkasLas->getJenisAsistensi()==$i){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		if ($i == 1){
																			$jenisAsistensi = "Non Kunjungan";
																		} else if ($i==2){
																			$jenisAsistensi = "Kunjungan";
																		}
																		echo "<option value='{$i}' {$isSelected}>".$jenisAsistensi."</option>";
																	}
																?>
															</select>	
														</div>
													</div>
												</div>
												
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Media</label>
														<div class="controls">
															<select class="large m-wrap span6" name="BerkasLas.media" id="BerkasLasMedia">
																<option value='-1'>--Pilih Media--</option>
															<?php
																	$isSelected = '';
																	foreach  ($medias as $media){
																		if ($berkasLas != NULL){
																			if ($berkasLas->getMedia()==$media){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		
																		echo "<option value='{$media->getId()}' {$isSelected}>{$media->getNama()}</option>";
																	}
																?>
															</select>	
														</div>
													</div>
												</div>
											</div>
											<!--/row-->
											<div class="row-fluid">
												<div class="span6 ">
													<div class="control-group">
														<label class="control-label">Kategori Asistensi</label>
														<div class="controls">
															<select class="large m-wrap span6" name="BerkasLas.kategoriAsistensi" id="kategoriAsistensi">
																<option value='-1'>--Pilih Kategori Asistensi--</option>
															<?php
																	$isSelected = '';
																	foreach  ($kategoriAsistensis as $row){
																		if ($berkasLas != NULL){
																			if ($berkasLas->getKategoriAsistensi()==$row){
																				$isSelected = "selected='selected'";
																			} else {
																				$isSelected = "";
																			}
																		}
																		
																		echo "<option value='{$row->getId()}' {$isSelected}>{$row->getNama()}</option>";
																	}
																?>
															</select>	
														</div>
													</div>
												</div>
												
												<div class="span6">
																									
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>	
							<!-- tab table -->
							<div class="tab-pane" id="table">
								<div class="portlet box green" id="memberOfTrainingPanel" style="display: none">
									<div class="clearfix">
										<div class="btn-group">
											<button id="newParticipantBtn" class="btn green" onclick="addRow(event)">
											Tambah Peserta <i class="icon-plus"></i>
											</button>
										</div>										
									</div>
									<div class="portlet-body form">
										<!-- BEGIN FORM-->
										<div class="row-fluid">
											<div class="span12 ">
												<div class="tab-pane" id="table">
													<div class="box-content">
														<table class="table table-striped table-hover table-bordered" id="myTable" >
															<thead>
																<tr>
																	<th>Nama</th>
																	<th>Jenis Kelamin</th>
																	<th>Staff/Non Staff/Lainnya</th>
																	<th>Tindakan</th>
																</tr>
															</thead>
															<tbody>
																
																<?php
																	if ($memberOfTraining != NULL && is_array($memberOfTraining)){
																		$idx = 0;
																		
																		foreach ($memberOfTraining as $row){
																			$isLainnyaChecked = "";
																			$isStaffChecked = "";
																			$isNonStaffChecked = "";
																			if ($row->getGender() == "M"){
																				$isMaleChecked = "checked";
																				$isFemaleChecked = "";
																			} else {
																				$isMaleChecked = "";
																				$isFemaleChecked = "checked";
																			}
																			
																			if ($row->getStaff() == "S"){
																				$isStaffChecked = "checked";
																				$isNonStaffChecked = "";
																			} else if ($row->getStaff() == "N"){
																				$isStaffChecked = "";
																				$isNonStaffChecked = "checked";
																			} else {
																				$isLainnyaChecked = "checked";
																			}
																			echo '<tr><td style="text-align: center;"><input class="m-wrap large" name="participantName[]" value="'.$row->getName().'" type="text"></td><td><div class="control-group" style="margin-bottom: 5px;">'.
										                                             '<div class="controls" style="margin-left: 20px;">'.                                                
										                                                '<label class="radio">'.
										                                                '<input type="radio" name="participantGender['.$idx.']" value="M" id="gender_' .$idx.'" '.$isMaleChecked.'/>'.
										                                                'Laki-Laki &nbsp;'.
										                                                '</label>'.
										                                                '<label class="radio">'.
										                                                '<input type="radio" name="participantGender['.$idx.']" value="F" id="gender2_' .$idx.'" '.$isFemaleChecked.'/>'.
										                                                'Perempuan'.
										                                                '</label>'.  
										                                             '</div>'.
										                                          '</div></td><td style="text-align: center;"><div class="control-group" style="margin-bottom: 5px;"><div class="controls" style="margin-left: 20px;">'.                                                
										                                                '<label class="radio">'.
										                                                '<input type="radio" name="participantStaff['.$idx.']" value="S" id="staff_' .$idx.'" '.$isStaffChecked.'/>'.
										                                                'Staff &nbsp;'.
										                                                '</label>'.
										                                                '<label class="radio">'.
										                                                '<input type="radio" name="participantStaff['.$idx.']" value="N" id="staff_' .$idx.'" '.$isNonStaffChecked.'/>'.
										                                                'Non Staff'.
										                                                '</label>&nbsp;&nbsp;'.
										                                                '<label class="radio">'.
										                                                '<input type="radio" name="participantStaff['.$idx.']" value="L" id="staff_' .$idx.'" '.$isLainnyaChecked.'/>'.
										                                                'Lainnya'.
										                                                '</label>'.  
										                                             '</div>'.
										                                          '</div></td><td><a onclick="deleteRow(event)" style="padding: 5px 12px;vertical-align: top" class="btn red"><i class="icon-remove m-icon-white"></i></a></td></tr>';
																				  $idx++;
																		}
																	} 
																?>
																<!--<tr><td><input class="m-wrap large" name="BerkasTraining.participant.name[]" value="" type="text"></td><td><label class="radio"><input value="M" name="gender[]" type="radio">Male</label>&nbsp;<label class="radio"><input value="F" name="gender[]" type="radio">Female</label></td><td><label class="radio"><input value="Staff" name="staff[]" type="radio">Staff</label>&nbsp;<label class="radio"><input value="Non" name="staff[]" type="radio">Non Staff</label></td><td><a onclick="" style="padding: 5px 12px;vertical-align: top" class="btn red"><i class="icon-remove m-icon-white"></i></a></td></tr>-->	
																	<!--<tr>
																		<td><input type="text" class="m-wrap large" name="BerkasTraining.participant.name[]" value="" /></td>
																		<td><label class="radio"><input type="radio"  value="M" name="gender[]" >Male</label>&nbsp;<label class="radio"><input type="radio" value="F" name="gender[]" />Female</label></td>
																		<td><label class="radio"><input type="radio" value="Staff" name="staff[]" >Staff</label>&nbsp;<label class="radio"><input type="radio" value="Non" name="staff[]" />Non Staff</label></td>
																		<td><a onclick="" style="padding: 5px 12px;vertical-align: top" class="btn red"><i class="icon-remove m-icon-white"></i></a></td>
																	</tr>-->															
															</tbody>
														</table>
													</div>
												</div>
											</div>													
										</div>
									</div>
								</div>
							</div>	
							<!-- end table -->
							
							<div class="tab-pane" id="attachmentTab">
								<div class="portlet">
									<div class="portlet-title line">
										<h4><i class="icon-file"></i></h4>										
									</div>
									<div class="portlet-body">
										<?php
											if ($berkas != NULL && $berkasAttachments != NULL){
												$i=0;
												foreach ($berkasAttachments as $berkasAttachment){
													$i++;
													echo '<div class="control-group">	
															<label class="control-label">File Lampiran</label>
								                              <div class="controls">
								                                 <div data-provides="fileupload" class="fileupload fileupload-exists"><input type="hidden" value="" name="">
								                                    <div class="input-append">
								                                       <div class="uneditable-input">
								                                          <i class="icon-file fileupload-exists"></i> 
								                                          <span class="fileupload-preview">'.$berkasAttachment->getPath().'</span>
								                                       </div>
								                                       <span class="btn btn-file">
								                                       <span class="fileupload-new">Pilih Dokumen</span>
								                                       <span class="fileupload-exists">Ubah</span>
								                                       <input type="file" class="default" name="attach'.$i.'" id="attach'.$i.'" >
								                                       </span>
								                                       <a data-dismiss="fileupload" class="btn fileupload-exists" href="#">Hapus</a>
								                                       <a class="btn blue" href="'.base_url().'inbox/viewBerkasAttachment/'.$berkasAttachment->getId().'" target="_blank">Lihat</a>
								                                    </div>
								                                 </div>
								                              </div>
								                           </div>';
														   
												}

												$x = 5 - $i;
												for ($j=0;$j<$x;$j++){
													$i++;
													echo '<div class="control-group">
										                    <label class="control-label">File Lampiran</label>
										                        <div class="controls">
										                            <div class="fileupload fileupload-new" data-provides="fileupload">
										                            	<div class="input-append">
										                                	<div class="uneditable-input">
										                                    	<i class="icon-file fileupload-exists"></i> 
										                                        <span class="fileupload-preview"></span>
										                                    </div>
										                                <span class="btn btn-file">
										                                <span class="fileupload-new">Pilih Dokumen</span>
										                                <span class="fileupload-exists">Ubah</span>
										                                	<input type="file" name="attach'.($i).'" class="default" id="attach'.$i.'"/>
										                                </span>
										                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Hapus</a>
										                                </div>
										                            </div>
										                         </div>
										                </div>';
												}										
											} else {
										?>
										<div class="control-group">
						                    <label class="control-label">File Lampiran</label>
						                        <div class="controls">
						                            <div class="fileupload fileupload-new" data-provides="fileupload">
						                            	<div class="input-append">
						                                	<div class="uneditable-input">
						                                    	<i class="icon-file fileupload-exists"></i> 
						                                        <span class="fileupload-preview"></span>
						                                    </div>
							                                <span class="btn btn-file">
							                                <span class="fileupload-new">Pilih Dokumen</span>
							                                <span class="fileupload-exists">Ubah</span>
							                                	<input type="file" name="attach1" class="default" id="attach1"/>
							                                </span>
							                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Hapus</a>
						                                </div>
						                            </div>
						                         </div>
						                </div>
						                
						                <div class="control-group">
						                    <label class="control-label">File Lampiran</label>
						                        <div class="controls">
						                            <div class="fileupload fileupload-new" data-provides="fileupload">
						                            	<div class="input-append">
						                                	<div class="uneditable-input">
						                                    	<i class="icon-file fileupload-exists"></i> 
						                                        <span class="fileupload-preview"></span>
						                                    </div>
						                                <span class="btn btn-file">
						                                <span class="fileupload-new">Pilih Dokumen</span>
						                                <span class="fileupload-exists">Ubah</span>
						                                	<input type="file" name="attach2" class="default" id="attach2"/>
						                                </span>
						                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Hapus</a>
						                                </div>
						                            </div>
						                         </div>
						                </div>
						                
						                <div class="control-group">
						                    <label class="control-label">File Lampiran</label>
						                        <div class="controls">
						                            <div class="fileupload fileupload-new" data-provides="fileupload">
						                            	<div class="input-append">
						                                	<div class="uneditable-input">
						                                    	<i class="icon-file fileupload-exists"></i> 
						                                        <span class="fileupload-preview"></span>
						                                    </div>
						                                <span class="btn btn-file">
						                                <span class="fileupload-new">Pilih Dokumen</span>
						                                <span class="fileupload-exists">Ubah</span>
						                                	<input type="file" name="attach3" class="default" id="attach3"/>
						                                </span>
						                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Hapus</a>
						                                </div>
						                            </div>
						                         </div>
						                </div>
						                
						                <div class="control-group">
						                    <label class="control-label">File Lampiran</label>
						                        <div class="controls">
						                            <div class="fileupload fileupload-new" data-provides="fileupload">
						                            	<div class="input-append">
						                                	<div class="uneditable-input">
						                                    	<i class="icon-file fileupload-exists"></i> 
						                                        <span class="fileupload-preview"></span>
						                                    </div>
						                                <span class="btn btn-file">
						                                <span class="fileupload-new">Pilih Dokumen</span>
						                                <span class="fileupload-exists">Ubah</span>
						                                	<input type="file" name="attach4" class="default" id="attach4"/>
						                                </span>
						                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Hapus</a>
						                                </div>
						                            </div>
						                         </div>
						                </div>
						                
						                <div class="control-group">
						                    <label class="control-label">File Lampiran</label>
						                        <div class="controls">
						                            <div class="fileupload fileupload-new" data-provides="fileupload">
						                            	<div class="input-append">
						                                	<div class="uneditable-input">
						                                    	<i class="icon-file fileupload-exists"></i> 
						                                        <span class="fileupload-preview"></span>
						                                    </div>
						                                <span class="btn btn-file">
						                                <span class="fileupload-new">Pilih Dokumen</span>
						                                <span class="fileupload-exists">Ubah</span>
						                                	<input type="file" name="attach5" class="default" id="attach5"/>
						                                </span>
						                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Hapus</a>
						                                </div>
						                            </div>
						                         </div>
						                </div>	
										
										<?php
											}
										?>
									</div>
								</div>
							</div>
							<!-- END OF ATTACHMENT -->
							
							<!-- START OF KONTRIBUSI -->
							<div class="tab-pane" id="kontribusiTab">
								<div class="portlet">
									<div class="portlet-title line">
										<h4><i class="icon-book"></i></h4>										
									</div>
									<div class="portlet-body">
										<div class="control-group">
											
	                                       <div class="controls">
	                                       	  <?php 
	                                       	    $berkasKontribusix = array();
	                                       	  	if (count($berkasKontribusis) > 0){
	                                       	  		foreach ($berkasKontribusis as $row){
														$berkasKontribusix[] = $row->getKontribusi();														
													}
	                                       	  	}
												$initVal = '';
	                                       	    foreach ($kontribusis as $kontribusi){
	                                       	    	if (count($berkasKontribusis) > 0 ){
	                                       	    		//foreach ($berkasKontribusis as $berkasKontribusi){
	                                       	    			if (in_array($kontribusi, $berkasKontribusix)){
		                                       	    		//if ($berkasKontribusi->getKontribusi() == $kontribusi){
		                                       	    			$checked = 'checked';
																//$initVal = $berkasKontribusi->getJumlah();
															} else {
		                                       	    			$checked = '';
																$initVal = '';
		                                       	    		}
															
															echo '<label class="checkbox line">
					                                          	<input type="checkbox" class="kontribusiclass" name="Kontribusi.'.$kontribusi->getNama().'" value="'.$kontribusi->getId().'" '.$checked.'/> '.$kontribusi->getLabel().' &nbsp;&nbsp;&nbsp;                                          													
					                                          </label>
					                                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
															if ($kontribusi->getId() == 7){
																$key = array_search($kontribusi, $berkasKontribusix);
																if ($key !== false) {
																	//var_dump($key);
																	//var_dump($berkasKontribusi);
																	$initVal = $berkasKontribusis[$key]->getNamaLain();
																}	
																echo '<input class="m-wrap large" id="berkasKontribusiLainnya" placeholder="Silahkan isi kontribusi lainnya" name="BerkasKontribusi.'.$kontribusi->getNama().'" type="text" value="'.$initVal.'" />';	
															}  
															
					                                          // <div class="input-prepend input-append">
																  // <span class="add-on">Rp</span><input class="m-wrap" name="BerkasKontribusi.'.$kontribusi->getNama().'.jumlah" type="text" value="'.$initVal.'" />
																  // <span class="add-on">'.$kontribusi->getUnit().'
																  // </span></div>';	
		                                       	    	
	                                       	    	} else {
	                                       	    		echo '<label class="checkbox line">
					                                          	<input type="checkbox" class="kontribusiclass" name="Kontribusi.'.$kontribusi->getNama().'" value="'.$kontribusi->getId().'" /> '.$kontribusi->getLabel().' &nbsp;&nbsp;&nbsp;
															  </label>
					                                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
														if ($kontribusi->getId() == 7){
																$key = array_search($kontribusi, $berkasKontribusix);
																if ($key !== false) {
																	$initVal = $berkasKontribusi[$key]->getNamaLain();
																}	
																echo '<input class="m-wrap large" id="berkasKontribusiLainnya" placeholder="Silahkan isi kontribusi lainnya" name="BerkasKontribusi.'.$kontribusi->getNama().'" type="text" value="'.$initVal.'" />';	
														}	  
					                                          // <div class="input-prepend input-append">
																  // <span class="add-on">Rp</span><input class="m-wrap" name="BerkasKontribusi.'.$kontribusi->getNama().'.jumlah" type="text" />
																  // <span class="add-on">'.$kontribusi->getUnit().'
																  // </span></div>';
	                                       	    	}	                                       	  		
	                                       	  	} 
	                                       	  ?>
	                                       </div>
	                                    </div>																	
									</div>
								</div>
							</div>							
							<!-- END OF KONTRIBUSI -->
							
							<div class="tab-pane" id="chatTab">
								<div class="portlet">
									<div class="portlet-title line">
										<h4><i class="icon-comments"></i></h4>
										<!--<div class="tools">
											<a class="collapse" href="javascript:;"></a>
											<a class="config" data-toggle="modal" href="#portlet-config"></a>
											<a class="reload" href="javascript:;"></a>
											<a class="remove" href="javascript:;"></a>
										</div> -->
									</div>
								<div id="chats" class="portlet-body">
									<div class="scroller" data-height="343px" data-always-visible="1" data-rail-visible1="1">
											<ul class="chats">
												<?php
													if ($berkasComments != null){
														foreach ($berkasComments as $berkasComment){
															$time = $berkasComment->getCreatedDate()->format('Y-m-d H:i:s'); 
															if ($berkasComment->getSender() == $userProfiles[0]->getUserId()){
																echo '<li class="in">
																		<div class="message">
																			<span class="arrow"></span>
																			<a class="name" href="#">'.$berkasComment->getSender().'</a>
																			<span class="datetime">at '.$time.'</span>
																			<span class="body">
																			'.$berkasComment->getText().'
																			</span>
																		</div>
																	</li>';			
															} else {
																echo '<li class="out">
																		<div class="message">
																			<span class="arrow"></span>
																			<a class="name" href="#">'.$berkasComment->getSender().'</a>
																			<span class="datetime">at '.$time.'</span>
																			<span class="body">'.$berkasComment->getText().'</span>
																		</div>
																	</li>'; 
															}
														}
													} ?>										
											</ul>
										</div>
								
								</div>
							</div>
							</div>
							
								
						</div>
					</div>
					<div class="form-actions">
						<button type="submit" class="btn blue" id="saveBtn">
							<i class="icon-ok"></i> Simpan Draft
						</button>
						<button type="submit" class="btn red" id="submitBtn">
							<i class="icon-ok"></i> Kirim Laporan
						</button>
						
						
						<button type="button" class="btn" id="cancelBtn">
								Batal
						</button>
					</div>
					</form>
					<!-- END FORM-->
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>
		<!-- END PAGE CONTAINER -->	
	</div>
	<!-- END PAGE -->
</div>	
<!-- END CONTAINER -->	

<div id="cancelModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
		<h3 id="myModalLabel3"></h3>
	</div>
	<div class="modal-body">
		<p>Apakah anda ingin membatalkan laporan ini ?</p>				
	</div>
	<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true">Tidak</button>
		<button data-dismiss="modal" class="btn blue" id="confirmCancelBtn">Ya</button>
	</div>
</div>	

<!-- DIALOG -->
<div id="myNote" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
		<h3 id="myModalLabel1">Tambah Komentar</h3>		
	</div>
<div class="modal-body">
	<div class="portlet-body fuelux">
		<textarea id="note" style="width: 515px; height: 88px;"></textarea>	
	</div>	
</div>
	<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true">Tutup</button>
		<button class="btn yellow" id="saveNote">Simpan</button>
	</div>
</div>
<!-- END DIALOG -->	

<div class="modal hide fade" id="pleaseWaitDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width: 300;top: calc(50% - 200px) !important;left: calc(50% - 150px) !important;">
    <div class="modal-header">
       <h3>Mengirim data...</h3>
    </div>
    <div class="modal-body">
       <div class="progress progress-striped active">
           <div class="bar" style="width: 100%;"></div>
       </div>
 	</div>
</div>

<div id="alertModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
		<h3 id="myModalLabel2">Informasi</h3>
	</div>
	<div class="modal-body" id="alertMessage">
		
	</div>
	<div class="modal-footer">
		<button data-dismiss="modal" class="btn green">OK</button>
	</div>
</div>
<?php $this->load->view('footer')?>

<script>
	$(document).ready(function() {
		var isSizeAttach1 = true;
		var isSizeAttach2 = true;
		var isSizeAttach3 = true;
		var isSizeAttach4 = true;
		var isSizeAttach5 = true;
		$("#alertModal").draggable({
      		handle: ".modal-header"
  		});
  		
  		$('#berkasKontribusiLainnya').hide();
		if ($('#berkasKontribusiLainnya').val() != ''){
			$('#berkasKontribusiLainnya').show();
		}
		
		$('input.kontribusiclass[type=checkbox]').change( function() {
		   //alert("test  "+ this.checked + $(this).val());
		   if ($(this).val() == 7){
		   		if (this.checked){
		   			$('#berkasKontribusiLainnya').show();
		   		} else {
		   			$('#berkasKontribusiLainnya').hide();
		   		}	 
		   }   
		});
		if ($('#tipeBerkas').val() == "TRAINING"){
		    		$('#jenisTrainingGroup').show();
		    		$('#detailSection').show();	
		    		$('#memberOfTrainingPanel').show();
		    		$('#eventDateSection').hide();
		    		$('#dtPesertaTab').show();	
		    		$('#lkpmDetailSection').hide();	
		    		$('#kategoriKegiatanGroup').hide();
		    		$('#jenisKegiatanGroup').hide();  
		    		$('#lasDetailSection').hide();  
		    		$('#dtKontribusiTab').show();		
		} else if ($('#tipeBerkas').val() == "LKPM"){ 
		    		$('#kategoriKegiatanGroup').show();
		    		$('#jenisKegiatanGroup').show();		    		
		    		$('#eventDateSection').hide();
		    		$('#jenisTrainingGroup').hide();
		    		$('#detailSection').hide();
		    		$('#dtPesertaTab').hide();
		    		$('#lasDetailSection').hide();
		    		$('#lkpmDetailSection').show();
		    		$('#dtKontribusiTab').show();		    		
		 } else if ($('#tipeBerkas').val() == "LAS"){
		    		$('#kategoriKegiatanGroup').hide();
		    		$('#jenisKegiatanGroup').hide();		    		
		    		$('#eventDateSection').hide();
		    		$('#jenisTrainingGroup').hide();
		    		$('#detailSection').hide();
		    		$('#dtPesertaTab').hide();
		    		$('#dtKontribusiTab').hide();
		    		$('#lkpmDetailSection').hide();
		    		$('#lasDetailSection').show();
		}
		
		
		
		
		//var idx = 0;
		<?php if ($berkas != NULL){
				 if ($memberOfTraining != NULL && count($memberOfTraining) > 0){
				 	echo "var idx = ". (count($memberOfTraining) + 1).";";
				 }	else {
				 	echo "var idx = 0;";
				 }
			  } else {
			  	 echo "var idx = 0;";
			  }
		?>
		addRow = function (event){
			event.preventDefault();
			
			var newRowHtml = '<tr><td style="text-align: center;"><input class="m-wrap large" name="participantName[]" value="" type="text" id="participantName_' + idx + '"></td><td><div class="control-group" style="margin-bottom: 5px;">'+
                                             '<div class="controls" style="margin-left: 20px;">'+                                                
                                                '<label class="radio">'+
                                                '<input type="radio" name="participantGender['+idx+']" value="M" id="gender_' + idx +'" checked/>'+
                                                'Laki-Laki &nbsp;&nbsp;'+
                                                '</label>'+
                                                '<label class="radio">'+
                                                '<input type="radio" name="participantGender['+idx+']" value="F" id="gender2_' + idx +'"/>'+
                                                'Perempuan'+
                                                '</label>'+  
                                             '</div>'+
                                          '</div></td><td style="text-align: center;"><div class="control-group" style="margin-bottom: 5px;"><div class="controls" style="margin-left: 20px;">'+                                                
                                                '<label class="radio">'+
                                                '<input type="radio" name="participantStaff['+idx+']" value="S" id="staff_' + idx +'" checked/>'+
                                                'Staff &nbsp;&nbsp;&nbsp;'+
                                                '</label>'+
                                                '<label class="radio">'+
                                                '<input type="radio" name="participantStaff['+idx+']" value="N" id="staff_' + idx +'"/>'+
                                                'Non Staff'+
                                                '</label>&nbsp;&nbsp;&nbsp;'+
                                                '<label class="radio">'+
                                                '<input type="radio" name="participantStaff['+idx+']" value="L" id="staff_' + idx +'"/>'+
                                                'Lainnya'+
                                                '</label>'+  
                                             '</div>'+
                                          '</div></td><td><a onclick="deleteRow(event)" style="padding: 5px 12px;vertical-align: top" class="btn red"><i class="icon-remove m-icon-white"></i></a></td></tr>';				 
			$("#myTable > tbody").append(newRowHtml);
			$("#participantName_"+idx).focus();
			//$(':text:first').focus();
			idx++;			
		}		
		
		deleteRow = function (event) {
			//console.log('e.currentTarget : ' + $(event.currentTarget).attr('name'));
			$(event.currentTarget).closest('tr').remove();
 		}
		
		$('#btnEditMember').click(function(){
			var $tab = $('[data-toggle="tab"][href="#table"]');
			$tab.show();                  // Display the tab
		    $tab.tab('show'); 
		    location.hash = "#ancho";
		    $(document.body).scrollTop($('#ancho').offset().top);
		});
		
		var $mtab = $('[data-toggle="tab"][href="#tab_1"]');
		$mtab.click(function(e) {      // Binding for later use (for user interaction)
	        e.preventDefault();
	        if ($('#tipeBerkas').val()== "TRAINING"){
	        	hitungMemberOfTraining();	
	        }
	        
	        $mtab.tab('show');
	    });
	    
	    hitungMemberOfTraining = function(){
	    	console.log('hitung member of training');
	    	var jmlh = 0;
	    	var jmlhM = 0;
	    	var jmlhF= 0;
	    	var jmlhS= 0;
	    	var jmlhN= 0;
	    	var jmlhL= 0;
	    	$('input[name^=participantName]').each(function() {
			    console.log( this.value );
			    jmlh++;
			});
			$('input[name^=participantGender]').each(function() {
			    if ($(this).is(':checked') && $(this).val() == 'M') {
            		jmlhM++;
        		} else if ($(this).is(':checked') && $(this).val() == 'F') {
			    	jmlhF++;	
			    }
			});
			$('input[name^=participantStaff]').each(function() {
			    if ($(this).is(':checked') && $(this).val() == 'S') {
            		jmlhS++;
        		} else if ($(this).is(':checked') && $(this).val() == 'N') {
			    	jmlhN++;	
			    } else if ($(this).is(':checked') && $(this).val() == 'L') {
			    	jmlhL++;	
			    }
			});
			$('#participantTotal').val(jmlh);
			$('#participantTotalMale').val(jmlhM);
			$('#participantTotalFemale').val(jmlhF);
			$('#participantTotalStaff').val(jmlhS);
			$('#participantTotalNonStaff').val(jmlhN);
			$('#participantTotalLainnya').val(jmlhL);
	    	//alert(jmlh); 
	    }
		
		$('#submitBtn').click(function(event){
			event.preventDefault();
			/* validasi */
			/*if ($('#distrik').val() == "-1"){
				alert('District cannot be null...');
				return;
			}*/
			if ($('#perpus').val() == "-1"){
				// alert('Silahkan memilih perpustakaan.');
				var msg = 'Silahkan memilih perpustakaan.';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			if ($('#tipeBerkas').val() == "-1"){
				//alert('Silahkan memilih jenis laporan.');
				var msg = 'Silahkan memilih jenis laporan.';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			} else {
				if ($('#tipeBerkas').val() == "TRAINING"){
					if ($('#jenisTraining').val() == "-1"){
						// alert('Silahkan memilih jenis pelatihan.');
						var msg = 'Silahkan memilih jenis pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}	
					if ($('input[name^=participantName]').length <= 0 ){
						// alert('Silahkan masukkan data peserta pelatihan.');
						var msg = 'Silahkan masukkan data peserta pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasTrainingFromDate').val() == ""){
						var msg = 'Silahkan memilih tanggal mulai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasTrainingToDate').val() == ""){
						var msg = 'Silahkan memilih tanggal selesai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
				} else if ($('#tipeBerkas').val() == "LAS"){
					if ($('#BerkasLasJenisAsistensi').val() == "-1"){
						//alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih jenis asistensi.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					
					if ($('#kategoriAsistensi').val() == "-1"){
						//alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih kategori asistensi.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					
					if ($('#BerkasLasMedia').val() == "-1"){
						//alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih media asistensi.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasLasFromDate').val() == ""){
						var msg = 'Silahkan memilih tanggal mulai kegiatan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasLasToDate').val() == ""){
						var msg = 'Silahkan memilih tanggal selesai kegiatan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
				} else if ($('#tipeBerkas').val() == "LKPM"){
					if ($('#jenisKegiatan').val() == "-1"){
						// alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih jenis kegiatan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					} else {
						if ($('#berkasLkpmJumlahTotal').val() == "0" || $('#berkasLkpmJumlahTotal').val() == ""){
							// alert('Silahkan memasukkan jumlah peserta');
							var msg = 'Silahkan memasukkan jumlah peserta.';
							$('#alertMessage').html(msg);
							$('#alertModal').modal('show');
							return;
						}
						if ($('#topikKegiatan').val() == "-1"){
							var msg = 'Silahkan memasukkan topik kegiatan.';
							$('#alertMessage').html(msg);
							$('#alertModal').modal('show');
							return;
						}
						
						if ($('#kategoriKegiatan').val() == "3"){
							if (!$('#radio_1').attr('checked') && !$('#radio_2').attr('checked')){
								var msg = 'Silahkan memasukkan sasaran kegiatan.';
								$('#alertMessage').html(msg);
								$('#alertModal').modal('show');
								return;
							}
						} else {
							var xf = 0;
							$('input[name^=BerkasLkpmSasaran]').each(function() {
								if (!$(this).is(':checked')){
									xf++;
								}
							});
							if (xf == 0){
								var msg = 'Silahkan memasukkan kelompok sasaran kegiatan.';
								$('#alertMessage').html(msg);
								$('#alertModal').modal('show');
								return;
							}
						}
					}
					if ($('#BerkasLkpmFromDate').val() == ""){
						var msg = 'Silahkan memilih tanggal mulai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasLkpmToDate').val() == ""){
						var msg = 'Silahkan memilih tanggal selesai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
				}				
			}
			
			//alert($('input[name^=participantName]').length);
			
			/*if ($('#participantTotal').val() <= 0){
				alert('Silahkan masukkan data absensi pelatihan.');
				return;
			}*/
			var isBerkasNotNull = <?php if ($berkas != NULL) echo 1; else echo 0;?>;
			if (isBerkasNotNull == 1 ){
				var numBerkas = <?php if ($berkasAttachments != NULL) echo count($berkasAttachments); else echo 0;?>;
				if (numBerkas == 0 && ($('#attach1').val() == "" && $('#attach2').val() == "" && 
					$('#attach3').val() == "" && $('#attach4').val() == "" && $('#attach5').val() == "")){
					//alert('Silahkan lampirkan file pendukung.');
					var msg = 'Silahkan lampirkan file pendukung.';
					$('#alertMessage').html(msg);
					$('#alertModal').modal('show');
					return;
				}	
			} else {
				if ($('#attach1').val() == "" && $('#attach2').val() == "" && 
					$('#attach3').val() == "" && $('#attach4').val() == "" && $('#attach5').val() == ""){
					//alert('Silahkan lampirkan file pendukung.');
					var msg = 'Silahkan lampirkan file pendukung.';
					$('#alertMessage').html(msg);
					$('#alertModal').modal('show');
					return;
				}		
			} 
						
			if (isSizeAttach1 == false){
				var msg = 'Silahkan perbaiki lampiran 1. ukuran lampiran melebihi yang batas lampiran yang diijinkan';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			if (isSizeAttach2 == false){
				var msg = 'Silahkan perbaiki lampiran 2. ukuran lampiran melebihi yang batas lampiran yang diijinkan';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			if (isSizeAttach3 == false){
				var msg = 'Silahkan perbaiki lampiran 3. ukuran lampiran melebihi yang batas lampiran yang diijinkan';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			if (isSizeAttach4 == false){
				var msg = 'Silahkan perbaiki lampiran 4. ukuran lampiran melebihi yang batas lampiran yang diijinkan';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			if (isSizeAttach5 == false){
				var msg = 'Silahkan perbaiki lampiran 5. ukuran lampiran melebihi yang batas lampiran yang diijinkan';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			var status = "<?php if ($berkas!=NULL) echo $berkas->getInbox()->getCondition(); else echo "";?>";
			if (status=="NOK"){
				$('#myNote').modal('show');	
			} else {
				$('#pleaseWaitDialog').modal('show');
				$('#editReportFrm').attr('action', "<?php echo base_url()?>inbox/saveAndSubmitReport").submit();	
			}	  		
	  	});
	  	
	  	/*
	  	$('#saveNote').click(function(){
			var textNote = $('#note').val();
			$('#berkasNote').val(textNote);
			$('#myNote').modal('hide');
			$('#editReportFrm').attr('action', "<?php echo base_url()?>inbox/saveAndSubmitReport").submit(); */
	//	}); 
		
		
		$('#saveNote').click(function(){
			var textNote = $('#note').val();
			if (textNote==''){
				//alert('Silahkan Tuliskan Komentar');
				var msg = 'Silahkan tuliskan komentar.';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			} else {
				$('#berkasNote').val(textNote);
				$('#myNote').modal('hide');
				$('#editReportFrm').attr('action', "<?php echo base_url()?>inbox/saveAndSubmitReport").submit();
			}
		});
	  	
	  	$('#saveBtn').click(function(event){
			/*  validasi */
			event.preventDefault();
			/*if ($('#distrik').val() == "-1"){
				alert('District cannot be null...');
				return;
			}*/
			
			if ($('#perpus').val() == "-1" || $('#perpus').val() == null){
				// alert('Silahkan memilih perpustakaan');
				var msg = 'Silahkan memilih perpustakaan.';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			}
			
			if ($('#tipeBerkas').val() == "-1"){
				// alert('Silahkan memilih jenis laporan.');
				var msg = 'Silahkan memilih jenis laporan.';
				$('#alertMessage').html(msg);
				$('#alertModal').modal('show');
				return;
			} else {
				if ($('#tipeBerkas').val() == "TRAINING"){
					if ($('#jenisTraining').val() == "-1"){
						// alert('Silahkan memilih jenis pelatihan.');
						var msg = 'Silahkan memilih jenis pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}	
					if ($('#BerkasTrainingFromDate').val() == ""){
						var msg = 'Silahkan memilih tanggal mulai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasTrainingToDate').val() == ""){
						var msg = 'Silahkan memilih tanggal selesai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
				} else if ($('#tipeBerkas').val() == "LKPM"){
					if ($('#jenisKegiatan').val() == "-1"){
						// alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih jenis kegiatan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					} else {
						if ($('#berkasLkpmJumlahTotal').val() == "0" || $('#berkasLkpmJumlahTotal').val() == ""){
							// alert('Silahkan memasukkan jumlah peserta');
							var msg = 'Silahkan memasukkan jumlah peserta.';
							$('#alertMessage').html(msg);
							$('#alertModal').modal('show');
						}
						if ($('#topikKegiatan').val() == "-1"){
							var msg = 'Silahkan memasukkan topik kegiatan.';
							$('#alertMessage').html(msg);
							$('#alertModal').modal('show');
						}
						
						if ($('#kategoriKegiatan').val() == "3"){
							if (!$('#radio_1').attr('checked') && !$('#radio_2').attr('checked')){
								var msg = 'Silahkan memasukkan sasaran kegiatan.';
								$('#alertMessage').html(msg);
								$('#alertModal').modal('show');
							}
						} else {
							var xf = 0;
							$('input[name^=BerkasLkpmSasaran]').each(function() {
								if (!$(this).is(':checked')){
									xf++;
								}
							});
							if (xf == 0){
								var msg = 'Silahkan memasukkan kelompok sasaran kegiatan.';
								$('#alertMessage').html(msg);
								$('#alertModal').modal('show');
							}
						}
					}
					if ($('#BerkasLkpmFromDate').val() == ""){
						var msg = 'Silahkan memilih tanggal mulai kegiatan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasLkpmToDate').val() == ""){
						var msg = 'Silahkan memilih tanggal selesai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
				} else if ($('#tipeBerkas').val() == "LAS"){
					if ($('#BerkasLasJenisAsistensi').val() == "-1"){
						//alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih jenis asistensi.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					
					if ($('#kategoriAsistensi').val() == "-1"){
						//alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih kategori asistensi.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					
					if ($('#BerkasLasMedia').val() == "-1"){
						//alert('Silahkan memilih jenis kegiatan.');
						var msg = 'Silahkan memilih media asistensi.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasLasFromDate').val() == ""){
						var msg = 'Silahkan memilih tanggal mulai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
					if ($('#BerkasLasToDate').val() == ""){
						var msg = 'Silahkan memilih tanggal selesai pelatihan.';
						$('#alertMessage').html(msg);
						$('#alertModal').modal('show');
						return;
					}
				} 				
			}
	  		$('#editReportFrm').submit();
	  	});
	  	
	  	 $('#distrik').on('change', function(e) {
		    // triggers when whole value changed
		    //alert('change');
		    	console.log("district value changed");
		    	var distrikId = $('#distrik').val();
		    	if (distrikId == "-1"){
		    		return;
		    	}
		    	// GET LIBRARY COMBOBOX
		    	$("#desa").empty();
				$("#desa").append($("<option></option>").attr("value", "-1").text("--Pilih Desa--")); 
		    	$.ajax({
				  url: "<?php echo base_url()?>reference/desaByDistrik/"+distrikId,
				  success: function(data){
				  	 	/*if (data.error == 1){
				  			console.log("ERROR FETCHING DISTRIK");						
				  		} 				  		
				  	 	if (data.success == 1){
				  	 		
				  	 	} */
				  	 	
				  	 	$.each(data, function(key, val) {
							 $("#desa").append($("<option></option>")
							 .attr("value", val.value).text(val.nama));
						});
						$('#desa').trigger("liszt:updated");
				  },
				  dataType: "json"
				});
				// END GET LIBRARY COMBOBOX
		  });
		  
		  $('#desa').on('change', function(e) {
		    // triggers when whole value changed
		    //alert('change');
		    	console.log("desa value changed");
		    	var desaId = $('#desa').val();
		    	if (desaId == "-1"){
		    		return;
		    	}
		    	
		    	$("#perpus").empty();
		    	//$("#perpus").append($("<option></option>").attr("value", "-1").text("--Pilih Perpustakaan--"));
		    	// GET LIBRARY COMBOBOX 
		    	$.ajax({
				  url: "<?php echo base_url()?>reference/perpustakaanByDesa/"+desaId,
				  success: function(data){
				  	 	/*if (data.error == 1){
				  			console.log("ERROR FETCHING DISTRIK");						
				  		} 				  		
				  	 	if (data.success == 1){
				  	 		
				  	 	} */
				  	 	
				  	 	$.each(data, function(key, val) {
							 $("#perpus").append($("<option></option>")
							 .attr("value", val.value).text(val.nama));
						});
						$('#perpus').trigger("liszt:updated");
				  },
				  dataType: "json"
				});
				// END GET LIBRARY COMBOBOX
		  });
		  
		  $('#tipeBerkas').on('change', function(e) {
		    	console.log("district value changed");
		    	if ($(this).val() == "TRAINING"){
		    		$('#jenisTrainingGroup').show();
		    		$('#detailSection').show();	
		    		$('#memberOfTrainingPanel').show();
		    		$('#eventDateSection').hide();
		    		$('#dtPesertaTab').show();	
		    		$('#lkpmDetailSection').hide();	
		    		$('#kategoriKegiatanGroup').hide();
		    		$('#jenisKegiatanGroup').hide();  
		    		$('#lasDetailSection').hide();  
		    		$('#dtKontribusiTab').show();		
		    	} else if ($(this).val() == "LKPM"){ 
		    		$('#kategoriKegiatanGroup').show();
		    		$('#jenisKegiatanGroup').show();		    		
		    		$('#eventDateSection').hide();
		    		$('#jenisTrainingGroup').hide();
		    		$('#detailSection').hide();
		    		$('#dtPesertaTab').hide();
		    		$('#lasDetailSection').hide();
		    		$('#lkpmDetailSection').show();
		    		$('#dtKontribusiTab').show();		    		
		    	} else if ($(this).val() == "LAS"){
		    		$('#kategoriKegiatanGroup').hide();
		    		$('#jenisKegiatanGroup').hide();		    		
		    		$('#eventDateSection').hide();
		    		$('#jenisTrainingGroup').hide();
		    		$('#detailSection').hide();
		    		$('#dtPesertaTab').hide();
		    		$('#dtKontribusiTab').hide();
		    		$('#lkpmDetailSection').hide();
		    		$('#lasDetailSection').show();
		    	} else {
		    		$('#jenisTrainingGroup').hide();
		    		$('#detailSection').hide();
		    		$('#memberOfTrainingPanel').hide();
		    				    		
		    	}		   		 	
		  });	
		 
		 $('#kategoriKegiatan').on('change', function(e){
		 	//alert('combro');
		 	var jenis = 1;
		 	if ($(this).val() == 3){
		 		jenis=2;
		 		$('#sasaranLabel').text("Sasaran");
		 	} else {
		 		$('#sasaranLabel').text("Kelompok Sasaran");
		 	}
		 	
		 	$("#kelompokSasaran").html('');
			//$("#jenisKegiatan").append($("<option></option>").attr("value", "-1").text("--Pilih Jenis Kegiatan--"));
			
		    $.ajax({
				  url: "<?php echo base_url()?>reference/kelompokSasaranByJenis/"+jenis,
				  success: function(data){
				  		var yhtml = ''; 
				  		var i = 1;
				  	 	$.each(data, function(key, val) {
				  	 		/*var xhtml =  '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="checkbox line">'+
						                   '<input type="checkbox" name="BerkasLkpmSasaran[]" value="'+val.value+'"/>'+val.nama+                                          													
							            '</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';*/
							// yhtml = '<label class="checkbox"><input type="checkbox" value="'+val.value+'" name="BerkasLkpmSasaran[]" >'+val.nama+' </label>';
							if (jenis==1){
								yhtml = '<label class="checkbox line"><div id="uniform-undefined" class="checker"><span><input type="checkbox" value="'+val.value+'" name="BerkasLkpmSasaran[]" onclick="sasaranClickHandler(event)"></span></div> '+val.nama+' &nbsp;&nbsp;&nbsp;</label>';	
							} else if (jenis==2){
								var inputTambahan = '';
								var spasi = '';
								var idName = '';
								if (val.nama.toUpperCase() == "NON PEMERINTAH"){
									idName = 'radio_1';
									//inputTambahan = '<input type="text" value="" id="kelompokNonPemerintah" name="kelompokNonPemerintah" class="m-wrap span6" >';
								} else {
									idName = 'radio_2';
									spasi = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
								}
								inputTambahan = '<input type="text" value="" id="kelompokNonPemerintah'+idName+'" name="kelompokNonPemerintah" class="m-wrap span6" >';
								yhtml = '<label class="radio line"><div id="uniform-undefined" class="radio"><span><input type="radio" name="BerkasLkpmSasaran[]" value="'+val.value+'" id="'+idName+'" onclick="sasaranRadioClickHandler(event)"></span></div>'
										                                  	+val.nama+
										                                  '&nbsp;&nbsp; '+ spasi + inputTambahan + '</label>';
								i++;		                                  
							}
							
							
							$("#kelompokSasaran").append(yhtml);
							
						});
						// $("#kelompokSasaran").html(yhtml);
				  },
				  dataType: "json"
			});
			
			
		 }); 
		 
		 
		 //$('input[name^=BerkasLkpmSasaran]').parents('span').removeClass("checked").end().removeAttr("checked").change();
		 sasaranClickHandler = function(event){
		 	
		 	console.log($(event.currentTarget).attr("name"));
		 	console.log($(event.currentTarget).is(':checked'));
		 	
		 	if ($(event.currentTarget).is(':checked')){
		 		//alert('a');
		 		//console.log($(event.currentTarget).val());
		 		//console.log($(event.currentTarget).parents('span'));
		 		$(event.currentTarget).parents('span').addClass("checked");
				$(event.currentTarget).attr("checked","checked");
		 			
		 	} else {
		 	//	alert('b');
		 		$(event.currentTarget).parents('span').removeClass("checked");
				$(event.currentTarget).removeAttr("checked");
		 		//console.log($(event.currentTarget).attr("name"));
		 		//$(this).attr("checked","checked");
		 		
		 	}
		 	
		 };
		 
		 sasaranRadioClickHandler = function(event){
		 	
		 	console.log($(event.currentTarget).attr("id"));
		 	console.log($(event.currentTarget).is(':checked'));
		 	if ($(event.currentTarget).attr("id") == "radio_1"){
		 		$('#radio_2').parents('span').removeClass("checked");
				$('#radio_2').removeAttr("checked");
				$('#radio_1').parents('span').addClass("checked");
				$('#radio_1').attr("checked","checked");
				$('#kelompokNonPemerintahradio_1').attr('disabled', false);
				$('#kelompokNonPemerintahradio_1').focus();
				$('#kelompokNonPemerintahradio_2').val('');
				$('#kelompokNonPemerintahradio_2').attr('disabled', true);
				
		 	} else {
		 		$('#radio_1').parents('span').removeClass("checked");
				$('#radio_1').removeAttr("checked");
				$('#radio_2').parents('span').addClass("checked");
				$('#radio_2').attr("checked","checked");
				$('#kelompokNonPemerintahradio_2').attr('disabled', false);
				$('#kelompokNonPemerintahradio_2').focus();
				$('#kelompokNonPemerintahradio_1').val('');
				$('#kelompokNonPemerintahradio_1').attr('disabled', true);
		 	}
		 	
		 };
		 
		 $('#kategoriKegiatan').on('change', function(e) {
		    // triggers when whole value changed
		    //alert('change');
		    	console.log("kategori kegiatan value changed");
		    	var kat = $('#kategoriKegiatan').val();
		    	if (kat == "-1"){
		    		return;
		    	}
		    	// GET JENISKEGIATAN COMBOBOX
		    	$("#jenisKegiatan").empty();
				$("#jenisKegiatan").append($("<option></option>").attr("value", "-1").text("--Pilih Jenis Kegiatan--")); 
		    	$.ajax({
				  url: "<?php echo base_url()?>reference/jenisKegiatanByKategori/"+kat,
				  success: function(data){
				  	 	
				  	 	$.each(data, function(key, val) {
							 $("#jenisKegiatan").append($("<option></option>")
							 .attr("value", val.value).text(val.nama));
						});
						$('#jenisKegiatan').trigger("liszt:updated");
				  },
				  dataType: "json"
				});
				// END GET JENISKEGIATAN COMBOBOX
				
				// GET JENISKEGIATAN COMBOBOX
		    	$("#topikKegiatan").empty();
				$("#topikKegiatan").append($("<option></option>").attr("value", "-1").text("--Pilih Topik Kegiatan--"));
				var jenisTopik = 1;
				if (kat == 3 || kat == '3'){
					jenisTopik = 2;
				} 
		    	$.ajax({
				  url: "<?php echo base_url()?>reference/topikKegiatanByKategori/"+jenisTopik,
				  success: function(data){
				  	 	
				  	 	$.each(data, function(key, val) {
							 $("#topikKegiatan").append($("<option></option>")
							 .attr("value", val.value).text(val.nama));
						});
						$('#topikKegiatan').trigger("liszt:updated");
				  },
				  dataType: "json"
				});
		  });
		  
		  
		  $('#BerkasLasJenisAsistensi').on('change', function(e) {
		    // triggers when whole value changed
		    //alert('change');
		    	console.log("BerkasLasJenisAsistensi value changed");
		    	var kat = $('#BerkasLasJenisAsistensi').val();
		    	if (kat == "-1"){
		    		return;
		    	}
		    	// GET kategoriAsistensi COMBOBOX
		    	$("#kategoriAsistensi").empty();
				$("#kategoriAsistensi").append($("<option></option>").attr("value", "-1").text("--Pilih Kategori Asistensi--")); 
		    	$.ajax({
				  url: "<?php echo base_url()?>reference/kategoriAsistensiByJenis/"+kat,
				  success: function(data){
				  	 	
				  	 	$.each(data, function(key, val) {
							 $("#kategoriAsistensi").append($("<option></option>")
							 .attr("value", val.value).text(val.nama));
						});
						$('#kategoriAsistensi').trigger("liszt:updated");
				  },
				  dataType: "json"
				});
				// END GET kategoriAsistensi COMBOBOX
				
				// GET media COMBOBOX
		    	$("#BerkasLasMedia").empty();
				$("#BerkasLasMedia").append($("<option></option>").attr("value", "-1").text("--Pilih Media Asistensi--"));
				 
		    	$.ajax({
				  url: "<?php echo base_url()?>reference/mediaAsistensiByJenis/"+kat,
				  success: function(data){
				  	 	
				  	 	$.each(data, function(key, val) {
							 $("#BerkasLasMedia").append($("<option></option>")
							 .attr("value", val.value).text(val.nama));
						});
						$('#BerkasLasMedia').trigger("liszt:updated");
				  },
				  dataType: "json"
				});
		  }); 
		 $('#hasilKegiatan').wysihtml5();
		 $('#tantangan').wysihtml5();
		 
		 $('#BerkasLkpmJumlahPria').change(function (){
		 	 var x = hitungJumlahPeserta();
		 	 $('#berkasLkpmJumlahTotal').val(x);
		 });
		 
		 $('#BerkasLkpmJumlahWanita').change(function (){
		 	 var x = hitungJumlahPeserta();
		 	 $('#berkasLkpmJumlahTotal').val(x);
		 }); 		
		 
		 hitungJumlahPeserta = function (){
		 	var pria;
		 	if ($('#BerkasLkpmJumlahPria').val() > 0){
		 		pria = 	$('#BerkasLkpmJumlahPria').val();
		 	} else {
		 		pria = 0;
		 	}
		 	
		 	var wanita;
		 	if ($('#BerkasLkpmJumlahWanita').val() > 0){
		 		wanita = 	$('#BerkasLkpmJumlahWanita').val();
		 	} else {
		 		wanita = 0;
		 	}
		 	
		 	return (parseInt(pria) + parseInt(wanita));
		 }
		 
		
	  	var cancelUrl;
	  	$('#cancelBtn').click(function(){
	  		//cancelUrl = '<?php echo base_url()."inbox/profile/"?>'+profileId;
	  		cancelUrl = "<?php echo base_url()."inbox/profile/".$selectedProfile;?>";
			$('#cancelModal').modal('show');
	  		//window.location = "<?php echo base_url()."inbox/profile/".$selectedProfile;?>";
	  		//window.location = cancelUrl;	
		});		   
		$('#confirmCancelBtn').click(function(){
	  		window.location = cancelUrl;
	  	});
	  	
	  	$("#attach1").live("change", function () {
	  		console.log('file change event dispatch');
		    if ($("input.file").val() == "") {
		        return;
		    }
		   GetFileSize($(this));		    
		});
		
		$("#attach2").live("change", function () {
	  		console.log('file change event dispatch');
		    if ($("input.file").val() == "") {
		        return;
		    }
		   GetFileSize($(this));		    
		});
		
		$("#attach3").live("change", function () {
	  		console.log('file change event dispatch');
		    if ($("input.file").val() == "") {
		        return;
		    }
		   GetFileSize($(this));		    
		});
		
		$("#attach4").live("change", function () {
	  		console.log('file change event dispatch');
		    if ($("input.file").val() == "") {
		        return;
		    }
		   GetFileSize($(this));		    
		});
		
		$("#attach5").live("change", function () {
	  		console.log('file change event dispatch');
		    if ($("input.file").val() == "") {
		        return;
		    }
		   GetFileSize($(this));		    
		});
		
		GetFileSize = function (inputFile) {
			console.log('GETFILESIZE dispatch');
			try {
				var fileSize = 0;
				//var inputFile = event.currentTarget();
				//for IE
				if ($.browser.msie) {
					//before making an object of ActiveXObject,
					//please make sure ActiveX is enabled in your IE browser
					var objFSO = new ActiveXObject("Scripting.FileSystemObject"); var filePath = $(inputFile)[0].value;
					var objFile = objFSO.getFile(filePath);
					var fileSize = objFile.size; //size in kb
					fileSize = fileSize / 1048576; //size in mb
				}
				//for FF, Safari, Opeara and Others
				else {
					fileSize = $(inputFile)[0].files[0].size //size in kb
					fileSize = fileSize / 1048576;  //size in mb
				}
				var elementId = $(inputFile).attr('id');
				//alert(elementId);	
				if (fileSize > 1){
					//alert("Maksimal file yang dapat diupload adalah 1 Mb, Ukuran file anda adalah : " + parseInt(fileSize) + 'Mb');
					var msg = "Maksimal file yang dapat diupload adalah 1 Mb, Ukuran file anda adalah : " + parseInt(fileSize) + 'Mb';
					$('#alertMessage').html(msg);
					$('#alertModal').modal('show');
					if (elementId == "attach1"){
						isSizeAttach1=false;
					} else if (elementId == "attach2"){
						isSizeAttach2=false;
					} else if (elementId == "attach3"){
						isSizeAttach3=false;
					} else if (elementId == "attach4"){
						isSizeAttach4=false;
					} else if (elementId == "attach5"){
						isSizeAttach5=false;
					}
				} else {
					if (elementId == "attach1"){
						isSizeAttach1=true;
					} else if (elementId == "attach2"){
						isSizeAttach2=true;
					} else if (elementId == "attach3"){
						isSizeAttach3=true;
					} else if (elementId == "attach4"){
						isSizeAttach4=true;
					} else if (elementId == "attach5"){
						isSizeAttach5=true;
					}
				}	
			} catch (e) {
				alert("Error is :" + e);
			}
		}
	});
</script>
<script type="text/javascript">

</script>